package com.pro.common.api.depencies.base;

import com.pro.common.api.CommonConst;
import com.pro.framework.api.model.IModel;
import com.pro.framework.api.util.CollUtils;
import io.swagger.v3.oas.annotations.Hidden;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

public interface ISaveBatchFeignClient<T extends IModel> {

    List<Long> saveBatch(@RequestBody List<T> list);

    default void saveBatchAndFillId(List<T> batchList) {
        List<Long> ids = saveBatch(batchList);  // 调用接口的远程方法
        CollUtils.forEach(ids, batchList, (id, batch) -> {
            batch.setId(id);
            return null;
        });
    }
}
